﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Metro.Kashikoi.ServiceContract.Location;

namespace Metro.Kashikoi.ServiceContract.Security
{
    public class SecurityServiceClient : ClientBase<ISecurityService>, ISecurityService
    {
        #region Constructor
        ///// <summary>
        ///// Initializes a new instance of the <see cref="SecurityServiceClient"/> class.
        ///// </summary>        
        //public SecurityServiceClient() { }

        /// <summary>
        /// Initializes a new instance of the <see cref="SecurityServiceClient"/> class.
        /// </summary>
        public SecurityServiceClient() :
            base("security") { }

        /// <summary>
        /// Initializes a new instance of the <see cref="SecurityServiceClient"/> class.
        /// </summary>
        /// <param name="remoteAddress">The remote address.</param>
        public SecurityServiceClient(string remoteAddress) :
            base("security", remoteAddress) { }
        #endregion

        /// <summary>
        /// Creates the user.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        public void CreateUser(User user)
        {
            base.Channel.CreateUser(user);
        }

        /// <summary>
        /// Creates the user group.
        /// </summary>
        /// <param name="userGroup">The user group.</param>
        /// <returns></returns>
        public void CreateUserGroup(UserGroup userGroup)
        {
            base.Channel.CreateUserGroup(userGroup);
        }

        /// <summary>
        /// Updates the user.
        /// </summary>
        /// <param name="user">The user.</param>
        public void UpdateUser(User user)
        {
            base.Channel.UpdateUser(user);
        }

        /// <summary>
        /// Updates the user group.
        /// </summary>
        /// <param name="userGroup">The user group.</param>
        public void UpdateUserGroup(UserGroup userGroup)
        {
            base.Channel.UpdateUserGroup(userGroup);
        }

        /// <summary>
        /// Deletes the user.
        /// </summary>
        /// <param name="user">The user.</param>
        public void DeleteUser(int id)
        {
            base.Channel.DeleteUser(id);
        }

        /// <summary>
        /// Deletes the user group.
        /// </summary>
        /// <param name="userGroupId">The user group id.</param>
        public void DeleteUserGroup(int userGroupId)
        {
            base.Channel.DeleteUserGroup(userGroupId);
        }

        /// <summary>
        /// Gets all users.
        /// </summary>
        /// <returns></returns>
        public IList<User> GetAllUsers()
        {
            return base.Channel.GetAllUsers();
        }

        /// <summary>
        /// Gets all user groups.
        /// </summary>
        /// <returns></returns>
        public IList<UserGroup> GetAllUserGroups()
        {
            return base.Channel.GetAllUserGroups();
        }

        /// <summary>
        /// Gets the user by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public User GetUserById(int id)
        {
            return base.Channel.GetUserById(id);
        }

        /// <summary>
        /// Gets the user by login.
        /// </summary>
        /// <param name="login">The login.</param>
        /// <returns></returns>
        public User GetUserByLogin(string login)
        {
            return base.Channel.GetUserByLogin(login);
        }

        /// <summary>
        /// Gets the user group by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public UserGroup GetUserGroupById(int id)
        {
            return base.Channel.GetUserGroupById(id);
        }

        /// <summary>
        /// Adds the user.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="userGroup">The user group.</param>
        public void AddUser(int userId, int userGroupId)
        {
            //TODO AddUser
            //  base.Channel.AddUser(user, userGroup);
        }

        /// <summary>
        /// Removes the user.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="userGroup">The user group.</param>
        public void RemoveUser(User user, UserGroup userGroup)
        {
            //  base.Channel.RemoveUser(user, userGroup);
        }

        /// <summary>
        /// Adds the route.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="region"></param>
        //public void AddRoute(User user, Region region)
        //{
        //    base.Channel.AddRoute(user, region);
        //}

        /// <summary>
        /// Removes the route.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="region"></param>
        //public void RemoveRoute(User user, Region region)
        //{
        //    base.Channel.RemoveRoute(user, region);
        //}

        //public bool ValidateUser(string id, string password)
        //{
        //    return base.Channel.ValidateUser(id, password);
        //}

        /// <summary>
        /// Mantains the GRP id.
        /// </summary>
        /// <param name="user">The user.</param>
        public void MantainGrpId(User user)
        {
            base.Channel.MantainGrpId(user);
        }

        /// <summary>
        /// Gets the user list.
        /// </summary>
        /// <param name="userGroupId"></param>
        /// <returns></returns>
        IList<User> ISecurityService.GetUserList(int userGroupId)
        {
            return base.Channel.GetUserList(userGroupId);
        }


        /// <summary>
        /// Adds the route.
        /// </summary>
        /// <param name="userGroup">The user group.</param>
        /// <param name="region"></param>
        public void AddRoute(UserGroup userGroup, Region region)
        {
            base.Channel.AddRoute(userGroup, region);
        }

        /// <summary>
        /// Removes the route.
        /// </summary>
        /// <param name="userGroup">The user group.</param>
        /// <param name="region">The region.</param>
        public void RemoveRoute(UserGroup userGroup, Region region)
        {
            base.Channel.RemoveRoute(userGroup, region);
        }


        #region ISecurityService Members


        public IList<UserGroup> GetUserGroupList(int userId)
        {
            throw new NotImplementedException();
        }

        public void AddUserToGroup(int userId, int userGroupId)
        {
            throw new NotImplementedException();
        }

        public void RemoveUserFromGroup(int userId, int userGroupId)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
